package com.jt.tenant.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.TextView;

import com.jt.tenant.R;
import com.jt.tenant.adapter.IllegalQueryAdapter;
import com.jt.tenant.app.JTApplication;
import com.jt.tenant.conn.GetViolation;
import com.jt.tenant.widget.Tools;
import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.util.UtilToast;

/**
 * 违章查询
 */
public class IllegalQueryActivity extends JTActivity implements View.OnClickListener{

    private TextView title_name;

    private ListView listView;

    private GetViolation getViolation = new GetViolation(new AsyCallBack<GetViolation.Info>(){

        @Override
        public void onSuccess(String toast, int type, final GetViolation.Info info) throws Exception {

            if(info.msg.equals("000")) {

                listView.setAdapter(new IllegalQueryAdapter(IllegalQueryActivity.this, info.violationList));

            }else {

                UtilToast.show(context,info.msg);

            }

        }

        @Override
        public void onFail(String toast, int type) throws Exception {

            super.onFail(toast, type);

        }
    });;

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_illegal_query);

        initView();

        initData();

    }

    private void initView() {

        (title_name= (TextView) findViewById(R.id.tv_title_name)).setText("违章查询");

        listView= (ListView) findViewById(R.id.listview_illegal_query);



    }

    private void initData(){

        if(!Tools.isPlateNO(JTApplication.jtPreferences.readPlateNum().trim())||!Tools.isVinNO(JTApplication.jtPreferences.readVincode().trim())){

            UtilToast.show(context,"请在车辆信息页面填写正确的车辆信息");

        }else {

            getViolation.execute(context);

        }


    }

    @Override
    protected void onResume() {

        super.onResume();

        initData();

    }

}
